package com.shuangfeidasan.service.pms.impl;

import com.shuangfeidasan.model.PmsCategory;
import com.shuangfeidasan.mapper.PmsCategoryMapper;
import com.shuangfeidasan.service.pms.PmsCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 产品表(PmsCategory)表服务实现类
 * @Author JunWEI
 * @Date 2022-03-22 22:08:48
 */
@Service("pmsCategoryService")
public class PmsCategoryServiceImpl implements PmsCategoryService {
    @Resource
    private PmsCategoryMapper pmsCategoryMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PmsCategory queryById(Long id) {
        return this.pmsCategoryMapper.queryById(id);
    }

    /**
     * 查询指定行
     *
     * @param pmsCategory 筛选条件
     * @return 查询结果
     */
    @Override
    public List<PmsCategory> queryAll(PmsCategory pmsCategory) {
        return this.pmsCategoryMapper.queryAll(pmsCategory);
    }

    /**
     * 新增数据
     *
     * @param pmsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public PmsCategory insert(PmsCategory pmsCategory) {
        this.pmsCategoryMapper.insert(pmsCategory);
        return pmsCategory;
    }

    /**
     * 修改数据
     *
     * @param pmsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public PmsCategory update(PmsCategory pmsCategory) {
        this.pmsCategoryMapper.update(pmsCategory);
        return this.queryById(pmsCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.pmsCategoryMapper.deleteById(id) > 0;
    }
}
